//
//    Copyright (C) 2012  OinkStudio
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

package oldClasses;

import java.util.ArrayList;
import java.util.Iterator;

public class MyTableInfo {

	private ArrayList<Object> fieldsList = new ArrayList<Object>();
	private int size;

	public MyTableInfo(Object[] fields) {
		int index = 0;

		while (index < fields.length) {
			fieldsList.add(fields[index]);
			index++;
		}
	}

	public void setSize(int size) {
		this.size = size;
	}

	public MyTableInfo() {
		super();
	}

	public Object getField(int index) {
		if (index < fieldsList.size()) {
			return fieldsList.get(index);
		}
		return null;

	}

	public int getIndex(Object element) {
		return fieldsList.indexOf(element);
	}

	public void addField(Object element, int index) {
		if (index < fieldsList.size()){
			fieldsList.add(index, element);
		}
		else{
			fieldsList.add(element);
		}

	}

	public boolean hasEmptyRow() {
		boolean answer = true;

		Iterator<Object> iteratorFields = fieldsList.iterator();

		while (iteratorFields.hasNext()) {
			if (iteratorFields.next() != null) {
				answer = false;
			}
		}

		return answer;
	}

}
